package wuuxiang.crm;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.LoadableComponent;
import org.testng.Assert;

public class Base1 extends LoadableComponent<Base1>{
	@FindBy(id = "j_username")
	private WebElement username;

	@FindBy(id = "j_password")
	private WebElement password;

	@FindBy(id = "shopcode")
	private WebElement jname;

	@FindBy(id = "j_captcha_response")
	private WebElement yzm;

	@FindBy(id = "login_shop_code")
	private WebElement confirm;
	
	
	private String url = "http://192.168.14.129:8080/shop/shoplogin/login.jsp";
	private String title = "客户关系管理平台";
	public WebDriver driver;
	public Base1(){
		System.setProperty("webdriver.firefox.bin", "D:/Firefox.exe");
		driver=new FirefoxDriver();
		PageFactory.initElements(driver, this);
	}
	//覆盖方法
	@Override
	protected void load(){
		this.driver.get(url);
	}
public void quit(){
	this.driver.quit();
}
public void login(){
	username.sendKeys("tcsl");
	password.sendKeys("123456");
	jname.sendKeys("1001");
	yzm.sendKeys("1234");
	confirm.click();
}
public WebDriver getDriver(){
	return driver;
}
//覆盖方法isLoaded
@Override
protected void isLoaded()throws Error{
	//断言访问后的页面Title是否包含“客户关系管理平台”这几个关键字
	//判断浏览器是否加载了正确的网址
	Assert.assertTrue(driver.getTitle().contains(title));
}



}
